<?php
	require_once("conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Formulario Busqueda</title>
<link href="Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<!--<script src="include_js/prototype.js" type="text/javascript"></script>-->
<script src="include_js/jquery.js" type="text/javascript"></script>
<!--<script src="include_js/select_dependientes.js" type="text/javascript"></script>-->

<script>
var arr = new Array();
var cont=0;

function borracampo()
{  
	if( document.form_Busqueda_fac.txtFactura.value == "Numero Factura")  
    document.form_Busqueda_fac.txtFactura.value = ""; 
}  

function restauracampo()
{  
  if((document.form_Busqueda_fac.txtFactura.value=="")||(document.form_Busqueda_fac.txtFactura.value!=""))
  document.form_Busqueda_fac.txtFactura.value="Numero Factura"; 
} 

function LimpiarCombo(combo)
{
	while(combo.length > 1)
	{
		combo.remove(combo.length-1);
	}
}
function LlenarCombo(json,combo){
	combo.options[0] = new Option('--Cliente--', '0');
	for(var i=0;i<json.length;i++)
	{
		combo.options[combo.length] = new Option(json[i].data, json[i].id);
	}
}
function SeleccionandoCombo(combo1, combo2)
{
	//alert(combo1.options[combo1.selectedIndex].value);
	combo2 = document.getElementById(combo2);
	//LimpiarCombo(combo2);
	if(combo1.options[combo1.selectedIndex].value != "0")
	{
		//combo1.disabled = true;
		//combo2.disabled = true;
		LimpiarCombo(combo2);
		$.ajax({
			type: 'post',
			dataType: 'json',
			url: 'Contabilidad/lista_Cliente.php',
			data: {valor: combo1.options[combo1.selectedIndex].value},
			success: function(json){
				LlenarCombo(json,combo2);
				//combo1.disabled = false;
				combo2.disabled = false;
			}
		});
	}
	else
	{
		LimpiarCombo(combo2);
		combo2.disabled = true;
	}
}
</script>

</head>

<body>
<form name="form_Busqueda_fac" id="form_Busqueda_fac" method="post">
<table width="100%" border="0" cellpadding="0">
  <tr>
    <td>
	<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Secci&oacute;n de busqueda.</label></div>
	<div class='groupbox'>
	<div id="capa" style="z-index:1;"></div>
	<table width="100%" border="0" class="tres" cellpadding="0" cellspacing="0">
  <tr style="border:1px solid #6593C0;">
    <td style="border:1px solid #6593C0;"><label style="color:#FFFFFF; font-weight:bold;">N&uacute;mero Factura</label></td>
    <td style="border:1px solid #6593C0;"><label style="color:#FFFFFF; font-weight:bold;">Area Extracci&oacute;n</label></td>
    <td style="border:1px solid #6593C0;"><label style="color:#FFFFFF; font-weight:bold;">Fecha Desde</label></td>
    <td style="border:1px solid #6593C0;"><label style="color:#FFFFFF; font-weight:bold;">Fecha Hasta</label></td>
    <td style="border:1px solid #6593C0;">&nbsp;</td>
  </tr>
  <tr style="border:1px solid #6593C0;">
    <td width="191" style="border:1px solid #6593C0;">
	<input name="txtFactura" id="txtFactura" type="text" value="Numero Factura" onclick="borracampo();" />	</td>
    <td width="332" style="border:1px solid #6593C0;">
		  <select name="cmb_Area" id="cmb_Area" style="z-index:1;" >
		  <option value="0">--Area Extraccion--</option>
		  <?php
            	$con = new Conexion();
        		$con2 = $con->conexionBD("fpproduccion");
                $sql = "select AECod,AENombre from areaextraccion order by AENombre";
                $resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
				$fila = mysql_num_rows($resultado);
				while ($row = mysql_fetch_row($resultado))
				{
					$nombre = utf8_decode($row[1]);
					echo "<option value='".$row[0]."'>".$nombre." "."(".$row[0].")"."</option>";
				}
                $con->cerrarBD();
		?>
		  </select>	</td>
    <td width="152" style="border:1px solid #6593C0;"><input name="txtFIni" type="text" id="txtFIni" size="10">&nbsp;<img src="imagen/img.gif" width="20" height="14" title="calendario" style="cursor: pointer; border: 1px solid green;" onmouseover="this.style.background='black';" onmouseout="this.style.background=''" onclick="popUpCalendar(txtFIni, form_Busqueda_fac.txtFIni, 'dd-mm-yyyy');" /></td>
    <td width="187" style="border:1px solid #6593C0;"><input name="txtFFin" type="text" id="txtFFin" size="10">&nbsp;<img src="imagen/img.gif" width="20" height="14" title="calendario" style="cursor: pointer; border: 1px solid green;" onmouseover="this.style.background='black';" onmouseout="this.style.background=''" onclick="popUpCalendar(txtFFin, form_Busqueda_fac.txtFFin, 'dd-mm-yyyy');" /></td>
    <td width="109" style="border:1px solid #6593C0;"><input name="btn_Buscar" id="btn_Buscar" type="button" value=" " class="buscar" /></td>
  </tr>
</table>		
      </div></td>
  </tr>
</table>
</form>
<table width="100%" border="0" cellpadding="2" cellspacing="0">
  <tr>
    <td><div id="listadoBusqueda"></div></td>
  </tr>
</table>
</body>
<script>
$('#btn_Buscar').click(function() 
{ 
	//alert("entro");
        $.ajax({
            type: 'POST',
            url: 'Contabilidad/carga_busqueda_Factura.php',
            data: $('#form_Busqueda_fac').serialize(),
            success: function(data) {
                $('#listadoBusqueda').html(data);
            }
        })
});
</script>
</html>